﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mql2Fdk;
using SoftFX.Basic;
using SoftFX.Extended;

namespace Mql2Fdk
{
	/// <summary>
	/// 
	/// </summary>
	public class BarPrices
	{
		internal BarPrices(BarPriceType type, MqlAdapter adapter)
		{
			m_type = type;
			m_adapter = adapter;
		}
		/// <summary>
		/// Gets 
		/// </summary>
		/// <param name="index"></param>
		/// <returns></returns>
		public double this[int index]
		{
			get
			{
				Snapshot snapshot = m_adapter.CurrentSnapshot;
				Bar bar = snapshot.Bars[index];
				if (BarPriceType.Open == m_type)
				{
					return bar.Open;
				}
				if (BarPriceType.Close == m_type)
				{
					return bar.Close;
				}
				if (BarPriceType.Low == m_type)
				{
					return bar.Low;
				}
				return bar.High;
			}
		}
		#region members
		private readonly BarPriceType m_type;
		private readonly MqlAdapter m_adapter;
		#endregion
	}
}
